<?php

require_once '../config.php';
$visitor = visitors_get_by_session_id(session_id());

if ($_POST) {
  messages_send_from_visitor($_POST['message'], $visitor);
}

?>

<html>
  <head>
  
    <style type="text/css">
      
      * {
        font-family:  Arial;
        font-size:    11px; 
      }
    
      body {
        padding:      10px;
        margin:       0px;
      }

      form {
        width:        100%;
      }

      textarea {
        width:        265px;
        height:       50px;
        border:       1px solid #ccc;
      }
      
    </style>
    
    <script type="text/javascript" src="/jquery.js"></script>
    <script type="text/javascript" src="/jquery.form.js"></script>
    <script type="text/javascript" src="/LcHelper.js"></script>
    <script type="text/javascript">
      
      $(document).ready(function() {
        LcHelper.refresh();
        $("#ClientChatMessageForm").ajaxForm(function() {
          $("#ClientChatMessage").val("");
          LcHelper.load();
        });
      });
    </script>
  </head>
  
  <body>
    <div style="width:253px;padding:5px;border:1px solid #ccc;margin-bottom:10px;height:167px;background:white">
      <a class="Periodical" rel="/visitor/ajax/messages.php?sessionId=<?php echo session_id() ?>"></a>
    </div>
    
    <form method="POST" action="/visitor/chat.php" id="ClientChatMessageForm">
      <textarea name="message" id="ClientChatMessage" style="background:white"></textarea><br />
      <input type="submit" value="Send" style="margin-right:100px;"/><!-- <a href="" style="color:#666">Powred by SalesHub</a> -->
      
    </form>
    
    <script type="text/javascript">
      LcHelper.load();
    </script>      
  </body>
  
</html>

